from flask import Blueprint

admin_bp = Blueprint("admin",__name__,url_prefix="/admin")

from .views import *


@admin_bp.before_request
def before_request():
    """是否是管理员的判断"""
    print(request.url)
    if request.url.endswith("/admin/login"):
        pass
    else:
        user_id = session.get("user_id")
        is_admin = session.get("is_admin",False)
        if not user_id or not is_admin:
            return redirect("/")